<template>
    <view>
        <view class="cu-card article" @tap="Detail" data-type="master" :data-val="oneMaster.Id" v-for="(oneMaster, index) in masterList" :key="index">
            <view class="cu-item shadow">
                <view class="title">
                    <view class="text-cut">
                        {{ oneMaster.title }}
                        <view class="cu-tag bg-gray light sm round" v-if="oneMaster.complete === 1">已归还</view>
                        <view class="cu-tag bg-green light sm round" v-if="oneMaster.complete === 0">未归还</view>
                        <view class="cu-tag bg-yellow light sm round" v-if="oneMaster.hasReward === 1">悬赏</view>
                    </view>
                </view>
                <view class="content">
                    <image v-if="oneMaster.hasImg === 1" :src="oneMaster.ImgUrl" mode="aspectFill"></image>
                    <view class="desc">
                        <view class="text-content">{{ oneMaster.content === '' ? '它没有编辑详情内容哦' : oneMaster.content }}</view>
                        <view>
                            <view class="cu-tag bg-red light sm round" v-for="(tag, index1) in oneMaster.tags" :key="index1">{{ tag }}</view>
                        </view>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
const app = getApp();
export default {
    data() {
        return {
            masterList: '',
            oneMaster: {
                Id: '',
                complete: 0,
                hasReward: 0,
                hasImg: 0,
                ImgUrl: '',
                content: '',
                tags: []
            },

            tag: ''
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function (options) {
		this.getData();
    },
    onPullDownRefresh: function () {
		this.getData();
    },
    methods: {

		getData: function(e){
			
			let that = this;
			uni.showLoading({
			    title: '加载中...'
			});
			uni.request({
			    url: app.globalData.ApiUrl + 'api/Android/masterList',
			    //这里填写你的接口路径
			    header: {
			        'Content-Type': 'application/json'
			    },
			
			    data: {
			        SafeCode: uni.getStorageSync('SafeCode')
			    },
			
			    method: 'POST',
			
			    success: function (res) {
			        that.setData({
			            masterList: res.data
			        });
			        uni.hideLoading();
			    }
			});
			uni.stopPullDownRefresh();
		},
        Detail: function (e) {
            var type = e.currentTarget.dataset.type;
            var val = e.currentTarget.dataset.val;
            uni.navigateTo({
                url: '../detail/detail?type=' + type + '&id=' + val
            });
        }
    }
};
</script>
<style>
@import './mymaster.css';
</style>
